package com.qb.main.ui.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.qb.main.R
import com.qb.common.bean.ImageBean
import com.qb.common.bean.MyImageBean
import com.qb.common.widget.GifWebView

class MyImageAdapter:BaseQuickAdapter<MyImageBean,BaseViewHolder>(R.layout.image_item) {
    override fun convert(holder: BaseViewHolder, item: MyImageBean) {
        holder.setText(R.id.tv_title,"${item.title}")
            .setText(R.id.tv_from,"来源：${item.from}")
            .setText(R.id.tv_good,"好评：${item.good}")
            .setText(R.id.tv_bad,"差评：${item.bad}")
        var iv_image = holder.getView<ImageView>(R.id.iv_png)
        var iv_gif = holder.getView<GifWebView>(R.id.iv_gif)
        var tv_joke_content = holder.getView<TextView>(R.id.tv_joke_content)
        iv_image.visibility = View.GONE
        iv_gif.visibility = View.GONE
        tv_joke_content.visibility = View.GONE
        if (item.img.startsWith("http")){
            iv_gif.visibility = View.VISIBLE
            iv_gif.loadGifUrl(item.img)
        }else{
            tv_joke_content.visibility = View.VISIBLE
            tv_joke_content.text = item.img
        }
    }
}